package com.zy.web.demo.suanfa.paisu;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/11/23 10:29
 */
public class test {

    public static void main(String[] args) {
        User u1=new User(1, 1, "A");
        User u2=new User(3, 2, "B");
        User u3=new User(3, 3, "C");
        User u4=new User(5, 4, "D");
        User u6=new User(3, 3, "C");
        User u5=new User(5, 5, "E");
        User u7=new User(1, 1, "A");
        ArrayList<User> list=new ArrayList<User>();
        list.add(u2);
        list.add(u5);
        list.add(u3);
        list.add(u4);
        list.add(u1);
        list.add(u6);
        list.add(u7);
        System.out.println("排序前：");
        for(int i=0;i<list.size();i++)
        {
            System.out.println("id："+list.get(i).getId() +" age:"+list.get(i).getAge() +"  name:"+list.get(i).getName());
        }
        System.out.println("排序后：");
        //id升序，age降序排序
        Collections.sort(list);
        for(int i=0;i<list.size();i++)
        {
            System.out.println("id："+list.get(i).getId() +" age:"+list.get(i).getAge() +"  name:"+list.get(i).getName());
        }
        System.out.println("");
    }

}
